import { createApp } from 'vue';
import App from './App.vue';
import { setupStore } from '@/stores';
import router, { setupRouter } from '@/router';
import { setupNaiveUi, setupElementPlus } from '@/plugin';
import { amfeFlexible, setupGlobalProperties } from '@/utils';
import setUpDirectives from '@/directives';
import 'virtual:svg-icons-register';

const bootstrap = async () => {
  const app = createApp(App);
  // 使用naive-ui
  setupNaiveUi(app);

  // 定义全局属性
  setupGlobalProperties(app);

  // 挂载状态管理
  setupStore(app);

  // 挂载路由
  setupRouter(app);

  // 自定义指令注册
  setUpDirectives(app);

  // 路由准备就绪后挂载 APP 实例
  // https://router.vuejs.org/api/interfaces/router.html#isready
  await router.isReady();

  await amfeFlexible(window, document);

  app.mount('#app');
};

void bootstrap();
